Vue.component("dropdown_comp", {
	props:['account'],
	data : function() {
		var data = {
				noti:"关闭",
				voice:"关闭",
				position_tip:null,
		}
		return data;

	},
	template : loadHTML("components/dropdown_comp/dropdown_comp.html"),
	ready : function() {
		console.log("注册下拉菜单点击事件");
		// 下拉菜单弹出动画
		$('.ui.top.right.dropdown.button').dropdown({
			action : 'hide'
		});
		
		sendRequest("isHidden", "post", "json",true, {account:this.account}, function(res){
			if(res.success){
				console.log(res.data);
				if(res.data==0){
					//不隐藏
					this.position_tip="隐藏";
				}else{
					this.position_tip="显示";
				}
			}
		}.bind(this));
		
	},
	methods : {
		showDropDown : function() {
			//console.log("下拉菜单打开");
			
		},
		click_item:function(opt){
			if(opt=="chat"){
				console.log("创建聊天");
				this.$emit("open_select_panel","create_chat");
			}
			if(opt=="close_desk_call"){
				console.log("关闭桌面提醒");
				if(this.noti=="关闭"){
					this.noti="打开";
					this.$emit("close_call","c_noti");
				}else{
					this.noti="关闭";
					this.$emit("close_call","o_noti");
				}
				
			}
			if(opt=="voice"){
				console.log("关闭声音提醒");
				if(this.voice=="关闭"){
					this.voice="打开";
					this.$emit("close_call","c_voice");
				}else{
					this.voice="关闭";
					this.$emit("close_call","o_voice");
				}
			}
			if(opt=="exit"){
				console.log("退出系统");
				sendRequest("exit", "post", "json", true, {account:this.account}, function(){
					window.location.reload();
				});
			}
			if(opt=="setposition"){
				if(this.position_tip=="隐藏"){
					//显示位置信息
					sendRequest("setPosition", "post", "json", false, {account:this.account,flag:"show"}, function(res){
						if(res.success){
							this.position_tip="显示";
						}
					}.bind(this));

				}
				else{
					//隐藏位置信息
					sendRequest("setPosition", "post", "json", false, {account:this.account,flag:"hidden"}, function(res){
						if(res.success){
							this.position_tip="隐藏";
						}
					}.bind(this));

				}
					
				}
			}
			
		
	}
});